<?php $this->load->view('common/head');?>
		<form class="form-horizontal margin-top-10" name="add" id="add" action="<?php echo $this->input->server('REQUEST_URI'); ?>" method="post">
		  <input type="hidden" name="id" id="id" value="<?=$projectData['id']?>">
		  <input type="hidden" name="procId" id="procId" value="<?=$procData['id']?>">
		  <input type="hidden" name="year" id="year" value="<?=$procData['year']?>">
		  <input type="hidden" name="timeUnit" id="timeUnit" value="<?=$procData['timeUnit']?>">
			<table class="table table-condensed table-bordered mb27">
			  <tbody>
			    <tr>
			      <td class="bg-primary col-md-1">投放类型：</td>
			      <td>
			      	<select required class="form-control" placeholder="" id="mediaType" name="mediaType">
		        		<option value="">请选择</option>
			        </select>
			      </td>
			    </tr>
			    <tr id="trmediaTypeAlias">
			      <td class="bg-primary col-md-1"></td>
			      <td>
			      	<input type="input" class="form-control" name="mediaTypeAlias" id="mediaTypeAlias" value="<?=$projectData['mediaTypeAlias']?>" placeholder="其它媒体类型">
			      </td>
			    </tr>
			    <tr>
			      <td class="bg-primary col-md-1">投放规格</td>
			      <td>
			      <input required type="input" class="form-control" name="mediaSize" id="mediaSize" value="<?=$projectData['mediaSize']?>" placeholder="投放规格">
			      </td>
			    </tr>
			    <tr id="trMediaSize">
			      <td class="bg-primary col-md-1">地址：</td>
			      <td>
				    <input required type="input" class="form-control" name="address" id="address" value="<?=$projectData['address']?>" placeholder="地址">
			      </td>
			    </tr>
			    <tr>
			      <td class="bg-primary col-md-1">合同时间</td>
			      <td>
			      <input type="input" required class="form-control" onFocus="WdatePicker({minDate:'<?=$this->config->item('spreadContractStart')?>',maxDate:'#F{$dp.$D(\'endTime\',{M:-5})||$dp.$DV(\'<?=$this->config->item('spreadContractEnd')?>\',{M:-5})}'})" name="startTime" id="startTime" value="<?=$projectData['contractStart']?>" placeholder="开始时间">
			      至
			      <input type="input" required class="form-control" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\',{M:5});}',maxDate:'<?=$this->config->item('spreadContractEnd')?>'})" name="endTime" id="endTime" value="<?=$projectData['contractEnd']?>" placeholder="结束时间">
			      </td>
			    </tr>
			    <tr>
			    	<td class="bg-primary col-md-1">合同</td>	
			    	<td>
			    		 <div>
			            <span id="contractFileDownload">
			            <?php if ($projectData['contractFile']['id']) {?>
			            <a type="button" class="btn btn-default" href="<?=printUrl('Upload','download',array('fileId'=>$projectData['contractFile']['id']))?>" aria-label="Left Align" role="button">
			              <span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span>
			              附件下载
			            </a>
			            <?php } ?>
			            </span>
			            <?php if ( in_array($action, array('edit')) ) {?>
			            <input type="hidden" id="contractFileFileId" name="contractFile" value="<?=$projectData['contractFile']['id']?>" readonly="readonly">
			            <input type="button" id="contractFile" value="上传" />
			            <span>仅能上传格式为压缩包，必须是完整合同版本。</span>
			            <?php } ?>
			            </div>
			    	</td>
			    </tr>
			    <tr>
			    	<td class="bg-primary col-md-1">发票</td>	
			    	<td>
			    		 <div>
			            <span id="invoiceFileDownload">
			            <?php if ($projectData['invoiceFile']['id']) {?>
			            <a type="button" class="btn btn-default" href="<?=printUrl('Upload','download',array('fileId'=>$projectData['invoiceFile']['id']))?>" aria-label="Left Align" role="button">
			              <span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span>
			              附件下载
			            </a>
			            <?php } ?>
			            </span>
			            <?php if ( in_array($action, array('edit')) ) {?>
			            <input type="hidden" id="invoiceFileFileId" name="invoiceFile" value="<?=$projectData['invoiceFile']['id']?>" readonly="readonly">
			            <input type="button" id="invoiceFile" value="上传" />
			            <span>仅能上传格式为压缩包</span>
			            <?php } ?>
			            </div>
			    	</td>
			    </tr>
			    <tr>
			    	<td class="bg-primary col-md-1">会签审批表</td>
			    	<td>
			    	仅能上传格式为.PDF .jpg .png，大小为3M以下。至少上传1张，最多可上传3张，必须是审批表签字件完整版本，结算口按照此凭证做全年费用预付。
			    		
			    	</td>	
			    </tr>
			    <tr>
			    	<td class="bg-primary col-md-1">审批表附件一</td>
			    	<td>
			    		<?php $id = 0; ?>
			    		<div id="auditTable<?=$id?>ImgBox"style="width:200px;overflow:hidden;">
			              <?php if ($projectData['auditTable'][$id]) {?>
			              <a target="_blank" href="<?=$projectData['auditTable'][$id]['viewPath']?>" class="thumbnail">
			                <img class="carousel-inner img-responsive img-rounded" src="<?=$projectData['auditTable'][$id]['viewPath']?>">
			              </a>
			              <?php } ?>
			            </div>
			            <?php if (in_array($action, array('edit'))) { ?>
			            <input type="hidden" id="auditTable<?=$id?>FileId" name="auditTable[]" value="<?=$projectData['auditTable'][$id]['id']?>" readonly="readonly">
			            <input type="button" id="auditTable<?=$id?>" value="上传" />
			            <?php } ?>
			    	</td>
			    </tr>
			    <tr>
			    	<td class="bg-primary col-md-1">审批表附件二</td>
			    	<td>
			    		<?php $id = 1; ?>
			    		<div id="auditTable<?=$id?>ImgBox"style="width:200px;overflow:hidden;">
			              <?php if ($projectData['auditTable'][$id]) {?>
			              <a target="_blank" href="<?=$projectData['auditTable'][$id]['viewPath']?>" class="thumbnail">
			                <img class="carousel-inner img-responsive img-rounded" src="<?=$projectData['auditTable'][$id]['viewPath']?>">
			              </a>
			              <?php } ?>
			            </div>
			            <?php if (in_array($action, array('edit'))) { ?>
			            <input type="hidden" id="auditTable<?=$id?>FileId" name="auditTable[]" value="<?=$projectData['auditTable'][$id]['id']?>" readonly="readonly">
			            <input type="button" id="auditTable<?=$id?>" value="上传" />
			            <?php } ?>
			    	</td>
			    </tr>
			    <tr>
			    	<td class="bg-primary col-md-1">审批表附件三</td>
			    	<td>
			    		<?php $id = 2; ?>
			    		<div id="auditTable<?=$id?>ImgBox"style="width:200px;overflow:hidden;">
			              <?php if ($projectData['auditTable'][$id]) {?>
			              <a target="_blank" href="<?=$projectData['auditTable'][$id]['viewPath']?>" class="thumbnail">
			                <img class="carousel-inner img-responsive img-rounded" src="<?=$projectData['auditTable'][$id]['viewPath']?>">
			              </a>
			              <?php } ?>
			            </div>
			            <?php if (in_array($action, array('edit'))) { ?>
			            <input type="hidden" id="auditTable<?=$id?>FileId" name="auditTable[]" value="<?=$projectData['auditTable'][$id]['id']?>" readonly="readonly">
			            <input type="button" id="auditTable<?=$id?>" value="上传" />
			            <?php } ?>
			    	</td>
			    </tr>
			    <tr>
			      <td class="bg-primary col-md-1">合同金额</td>
			      <td>
			      <input type="number" required min="0" step="0.01" class="form-control" name="applyMoney" id="applyMoney" value="<?=(float)$projectData['applyMoney']?$projectData['applyMoney']:''?>" placeholder="合同金额">
			      </td>
			    </tr>
			    <!-- <tr>
			      <td class="bg-primary col-md-1">备注</td>
			      <td>
			    			   		<textarea class="form-control" name="remark" id="remark" style="width: 300px; height: 100px;"><?=$projectData['remark']?></textarea>
			      </td>
			    </tr> -->
			    <tr>
			      <td colspan="2" align="center">
			    	<button type="submit" class="btn btn-default btn-primary">保存</button>
			  		<button class="btn btn-default btn-primary" type="button" onclick="window.location.href='<?=$breadcrumb[count($breadcrumb)-2]['url']?>'">返回</button>
			      </td>
			    </tr>
			    </tbody>
			  </table>
		</form>
<script type="text/javascript" src="public/js/commonSpread.js"></script>
<script type="text/javascript">
$(function(){
  initValidation();
  $("#trmediaTypeAlias").hide();
  loadMediaType(<?=$projectData['mediaType']?$projectData['mediaType']:0?>);
  mediaTypeAliasDisplay(<?=$projectData['mediaType']?$projectData['mediaType']:0?>);
  $("#mediaType").change(function(){
    mediaTypeAliasDisplay($("#mediaType").val());
    initValidation();
  });
});
//初始化验证
function initValidation(){
	$('form[name="add"]').find("input,select,textarea").jqBootstrapValidation("destroy");
	$('form[name="add"]').find("input,select,textarea").not("[type=submit]").jqBootstrapValidation({
	    preventSubmit:false,
	    submitSuccess: function (form, event) {
	         event.preventDefault();
	         ajaxFormSubmit('add');
	     },
	     submitError: function (form, event, errors) {
	       event.preventDefault();
	       }
  	});
}
</script>
<?php
if ( in_array($action, array('edit')) ) {
  initUploadButtons(array('contractFile','invoiceFile'), printUrl('Upload','uploadSave',array('dir'=>'settleFile')), 'imgFile');
  $auditTableIds = array('auditTable0','auditTable1','auditTable2');
  initUploadButtons($auditTableIds, printUrl('Upload','uploadSave',array('dir'=>'image')), 'imgFile'); 
}
?>
<?php $this->load->view('common/foot');?>